const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
+const PopupAnimation = {
+ NONE: 0,
+ SLIDE: 1 << 0,
+ FADE: 1 << 1,
+ FULL: ~0,
+};
+
const POPUP_ANIMATION_TIME = 0.15;
/**
show: function(animate, onComplete) {
let themeNode = this.actor.get_theme_node();
let rise = themeNode.get_length('-arrow-rise');
+ let animationTime = (animate & PopupAnimation.FULL) ? POPUP_ANIMATION_TIME : 0;
+
+ if (animate & PopupAnimation.FADE)
+ this.opacity = 0;
+ else
+ this.opacity = 255;
- this.opacity = 0;
this.actor.show();
- if (animate) {
+ if (animate & PopupAnimation.SLIDE) {
switch (this._arrowSide) {
case St.Side.TOP:
this.yOffset = -rise;
if (onComplete)
onComplete();
}),
- time: POPUP_ANIMATION_TIME });
+ time: animationTime });
},
hide: function(animate, onComplete) {
let yOffset = 0;
let themeNode = this.actor.get_theme_node();
let rise = themeNode.get_length('-arrow-rise');
+ let fade = (animate & PopupAnimation.FADE);
+ let animationTime = (animate & PopupAnimation.FULL) ? POPUP_ANIMATION_TIME : 0;
- if (animate) {
+ if (animate & PopupAnimation.SLIDE) {
switch (this._arrowSide) {
case St.Side.TOP:
yOffset = rise;
this._muteInput();
- Tweener.addTween(this, { opacity: 0,
+ Tweener.addTween(this, { opacity: fade ? 0 : 255,
xOffset: xOffset,
yOffset: yOffset,
transition: 'linear',
- time: POPUP_ANIMATION_TIME,
+ time: animationTime,
onComplete: Lang.bind(this, function () {
this.actor.hide();
+ this.opacity = 0;
this.xOffset = 0;
this.yOffset = 0;
if (onComplete)
this._summaryBoxPointerState = State.SHOWING;
this._clickedSummaryItem.actor.add_style_pseudo_class('selected');
- this._summaryBoxPointer.show(true, Lang.bind(this, function() {
+ this._summaryBoxPointer.show(BoxPointer.PopupAnimation.FULL, Lang.bind(this, function() {
this._summaryBoxPointerState = State.SHOWN;
}));
},
this._summaryBoxPointer.actor.hide();
this._hideSummaryBoxPointerCompleted();
} else {
- this._summaryBoxPointer.hide(true, Lang.bind(this, this._hideSummaryBoxPointerCompleted));
+ this._summaryBoxPointer.hide(BoxPointer.PopupAnimation.FULL, Lang.bind(this, this._hideSummaryBoxPointerCompleted));
}
},
_connectSubMenuSignals: function(object, menu) {
object._subMenuActivateId = menu.connect('activate', Lang.bind(this, function() {
this.emit('activate');
- this.close(true);
+ this.close(BoxPointer.PopupAnimation.FULL);
}));
object._subMenuActiveChangeId = menu.connect('active-changed', Lang.bind(this, function(submenu, submenuItem) {
if (this._activeMenuItem && this._activeMenuItem != submenuItem)
}));
menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
this.emit('activate', menuItem);
- this.close(true);
+ this.close(BoxPointer.PopupAnimation.FULL);
}));
// the weird name is to avoid a conflict with some random property
// the menuItem may have, called destroyId
menuItem._closingId = this.connect('open-state-changed',
function(self, open) {
if (!open)
- menuItem.close(false);
+ menuItem.close(BoxPointer.PopupAnimation.FADE);
});
menuItem.connect('destroy', Lang.bind(this, function() {
menuItem.disconnect(menuItem._subMenuActivateId);
this._connectItemSignals(menuItem);
menuItem._closingId = this.connect('open-state-changed', function(self, open) {
if (!open)
- menuItem.menu.close(false);
+ menuItem.menu.close(BoxPointer.PopupAnimation.FADE);
});
} else if (menuItem instanceof PopupSeparatorMenuItem) {
this._connectItemSignals(menuItem);
toggle: function() {
if (this.isOpen)
- this.close(true);
+ this.close(BoxPointer.PopupAnimation.FULL);
else
- this.open(true);
+ this.open(BoxPointer.PopupAnimation.FULL);
},
destroy: function() {
_onKeyPressEvent: function(actor, event) {
if (event.get_key_symbol() == Clutter.Escape) {
- this.close(true);
+ this.close(BoxPointer.PopupAnimation.FULL);
return true;
}
// Move focus back to parent menu if the user types Left.
if (this.isOpen && event.get_key_symbol() == Clutter.KEY_Left) {
- this.close(true);
+ this.close(BoxPointer.PopupAnimation.FULL);
this.sourceActor._delegate.setActive(true);
return true;
}
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Right) {
- this.menu.open(true);
+ this.menu.open(BoxPointer.PopupAnimation.FULL);
this.menu.actor.navigate_focus(null, Gtk.DirectionType.DOWN, false);
return true;
} else if (symbol == Clutter.KEY_Left && this.menu.isOpen) {
},
activate: function(event) {
- this.menu.open(true);
+ this.menu.open(BoxPointer.PopupAnimation.FULL);
},
_onButtonReleaseEvent: function(actor) {
_onKeyPressEvent: function(actor, event) {
if (event.get_key_symbol() == Clutter.Escape) {
- this.close(true);
+ this.close(BoxPointer.PopupAnimation.FULL);
return true;
}
let oldMenu = this._activeMenu;
this._activeMenu = null;
for (let i = this._menuStack.length - 1; i >= 0; i--)
- this._menuStack[i].close(false);
- oldMenu.close(false);
- newMenu.open(false);
+ this._menuStack[i].close(BoxPointer.PopupAnimation.FADE);
+ oldMenu.close(BoxPointer.PopupAnimation.FADE);
+ newMenu.open(BoxPointer.PopupAnimation.FADE);
} else
- newMenu.open(true);
+ newMenu.open(BoxPointer.PopupAnimation.FULL);
},
_onMenuSourceEnter: function(menu) {
_closeMenu: function() {
if (this._activeMenu != null)
- this._activeMenu.close(true);
+ this._activeMenu.close(BoxPointer.PopupAnimation.FULL);
}
});